package com.indictor.bean;

import java.math.BigDecimal;

public final class Indicator {

    private BigDecimal value;
    private final String key;
    private final String type;

    private final Indicator left;
    private final Indicator right;

    private IndicatorApplicationContext applicationContext = IndicatorApplicationContext.getInstance();

    public Indicator(String key, String type, BigDecimal decimal) {
        this.key = key;
        this.value = decimal;
        this.type = type;
        left = null;
        right = null;
    }

    public Indicator(String key, String type,  Indicator left, Indicator right) {
        this.key = key;
        this.type = type;
        this.left = left;
        this.right = right;
    }


    public Indicator getLeft() {
        return left;
    }

    public Indicator getRight() {
        return right;
    }

    public String getKey() {
        return key;
    }

    public String getType() {
        return type;
    }


    public BigDecimal getValue() {
        if (this.value != null) {
            return value;
        }
        return applicationContext.getParameterMap().get(this.getKey());
    }

    public void setValue(BigDecimal calculate) {
        this.value = calculate;
    }
}
